import pygame
import sys
from pygame.locals import *

pygame.init()

SCREEN_RESOLUTION_WIDTH = 1280
SCREEN_RESOLUTION_HEIGHT = 720
SCREEN_RESOLUTION = (SCREEN_RESOLUTION_WIDTH, SCREEN_RESOLUTION_HEIGHT)
SCREEN_OFFSET = (0, 0)
OBJECT_INIT_POS = (SCREEN_RESOLUTION_WIDTH, SCREEN_RESOLUTION_HEIGHT / 2)
OBJECT_CELL_SIZE = (83, 128)
SCREEN = pygame.display.set_mode(SCREEN_RESOLUTION)

# 绘制图片
import util.image as image
bg = image.Image('tex/other/bg.png', 0, SCREEN_OFFSET, SCREEN_RESOLUTION)
zombie = image.Image('tex/zombie/0/%d.png', 0, OBJECT_INIT_POS, OBJECT_CELL_SIZE, 7)

while True:
    for evt in pygame.event.get():
        if evt.type == QUIT:
            pygame.quit()
            sys.exit()
    
    SCREEN.fill((255, 255, 255))
    bg.draw(SCREEN)
    zombie.draw(SCREEN)
    zombie.doDirection()
    zombie.updateIdx((zombie.pathIdx + 1) % zombie.pathIdxCnt)
    pygame.display.update()